home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 March / EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso / earcd / util4 / fwcalndr.lha / FWCalendar / AddEvent.rexx next >
OS/2 REXX Batch file  |  1995-10-18  |  6KB  |  172 lines

  1. /* AddEvent Macro
  2.     Adds events to calendars created by my
  3.     Calendar Macro for FinalWriter3 (SoftWood)
  4.     Written by Ronald Goertz
  5.     $VER: AddEvent v1.0 (18 Feb 95)
  6.  */
  7.  
  8.  OPTIONS RESULTS
  9.  
  10.  SetMeasure MicroPoints
  11.  
  12.  /* User-defined variables ... these !should! correspond to the variables */
  13.  /* used in the Calendar macro                                            */
  14.     FullWidth        = 11.0
  15.     FullHeight       =  8.5
  16.     TopMargin        =  0.5
  17.     BottomMargin     =  0.2
  18.     LeftMargin       =  0.6
  19.     RightMargin      =  0.2
  20.  
  21.     Font             = "Work:WP.../FinalWriter/FWFonts/SWOLFonts/SoftSans"
  22.     FSize            = 8
  23.     FWidth           = 100
  24.  
  25.     TextOffset       = 0.05
  26.  
  27.  /* Program variables */
  28.     mpi              = 720
  29.     TextOffset       = trunc(TextOffset * mpi)
  30.     FullWidth        = trunc(FullWidth * mpi)
  31.     FullHeight       = trunc(FullHeight * mpi)
  32.     TopMargin        = trunc(TopMargin * mpi)
  33.     BottomMargin     = trunc(BottomMargin * mpi)
  34.     LeftMargin       = trunc(LeftMargin * mpi)
  35.     RightMargin      = trunc(RightMargin * mpi)
  36.  
  37.     PageWidth        = trunc(FullWidth - LeftMargin - RightMargin)
  38.     PageHeight       = trunc(FullHeight - TopMargin - BottomMargin)
  39.     TextArea         = trunc(.15 * PageHeight)
  40.     BoxWidth         = trunc(PageWidth/7)
  41.     BoxHeight        = trunc((PageHeight-TextArea)/5)
  42.  
  43.     MonthLength.1    = 31
  44.     MonthLength.2    = 28
  45.     MonthLength.3    = 31
  46.     MonthLength.4    = 30
  47.     MonthLength.5    = 31
  48.     MonthLength.6    = 30
  49.     MonthLength.7    = 31
  50.     MonthLength.8    = 31
  51.     MonthLength.9    = 30
  52.     MonthLength.10   = 31
  53.     MonthLength.11   = 30
  54.     MonthLength.12   = 31
  55.  
  56.  DisplayPrefs GUIDES a
  57.  TextBlockTypePrefs COLOR Black
  58.  TextBlockTypePrefs SIZE FSize WIDTH FWidth FONT font
  59.  BoxPrefs LINEWT Hairline FILL Solid FILLCOLOR White
  60.  
  61.  GetTextBlockText 2
  62.  TempDate = RESULT
  63.  SelectObject
  64.  
  65.  Month = substr(TempDate,5,2)
  66.  if left(Month,1) == "0" then Month = right(Month,1)
  67.  PrevMonth = Month - 1
  68.  if PrevMonth = 0 then PrevMonth = 12
  69.  
  70.  Year = left(TempDate,4)
  71.  if (Year//4 == 0 & Year//100 > 0) | Year//400 == 0 Then MonthLength.2  = 29
  72.  
  73.  StartDate = date('w',TempDate,'S')
  74.  Select
  75.     When StartDate == "Sunday"    Then StartDate = 0
  76.     When StartDate == "Monday"    Then StartDate = 1
  77.     When StartDate == "Tuesday"   Then StartDate = 2
  78.     When StartDate == "Wednesday" Then StartDate = 3
  79.     When StartDate == "Thursday"  Then StartDate = 4
  80.     When StartDate == "Friday"    Then StartDate = 5
  81.     When StartDate == "Saturday"  Then StartDate = 6
  82.  End
  83.  
  84.  Do While 1
  85.     Drop RESULT
  86.     RequestText '"Event Entry" "Enter event as: Day,Day,Line,Box,Event" ""'
  87.     input = RESULT
  88.     if input == "RESULT" | input == "" then Exit
  89.     Parse Var input Day1 ',' Day2 ',' Line ',' Box ',' Event
  90.  
  91.     Box = left(upper(Box),1)
  92.     if Box == 'B' | pos('//',Event) ~= 0 then Box = 'Y'
  93.  
  94.     If Day2 == "DAY2" | Day2 == "" then Day2 = Day1
  95.  
  96.     If upper(left(Day1,1)) == "P" then Day1 = substr(Day1,2) - MonthLength.PrevMonth
  97.     If upper(left(Day2,1)) == "P" then Day2 = substr(Day2,2) - MonthLength.PrevMonth
  98.     If upper(left(Day1,1)) == "N" then Day1 = substr(Day1,2) + MonthLength.Month
  99.     If upper(left(Day2,1)) == "N" then Day2 = substr(Day2,2) + MonthLength.Month
  100.  
  101.     If Day1 > Day2 then Do
  102.        TempDate = Day1
  103.        Day1 = Day2
  104.        Day2 = TempDate
  105.     End
  106.     If Day1 ~= Day2 then Box = 'Y'
  107.  
  108.     If Day1 <= -StartDate then Do
  109.        ShowMessage 1 0 '"Dates cannot come before" "the beginning of the calendar." "" "OK" "" ""'
  110.        Exit
  111.     End
  112.  
  113.     if ((StartDate + MonthLength.Month > 35) & (Day2 > MonthLength.Month)) | ((StartDate + MonthLength.Month < 36) & (Day2 > 35 - StartDate)) then do
  114.        ShowMessage 1 0 '"Dates cannot come after" "the end of the calendar." "" "OK" "" ""'
  115.        Exit
  116.     End
  117.  
  118. /*ShowMessage 1 0 ''TextRows' 'Text.TextRows' 'Found' "OK" "" ""'*/
  119.     Day1Row = trunc((Day1 + StartDate - 1)/7)
  120.     Day2Row = trunc((Day2 + StartDate - 1)/7)
  121.     Day1Column = (Day1 + StartDate) - 7*Day1Row - 1
  122.     LeftEdge = LeftMargin + Day1Column*BoxWidth + TextOffset
  123.     If Day1Row < 5 then PrintRow = Day1Row * BoxHeight
  124.     else PrintRow = trunc(4.5 * BoxHeight)
  125.     
  126.     If Box ~= 'Y' then do
  127.        TextBottom = TopMargin + TextArea + PrintRow + (Line+1)*FSize*11
  128.        TextLeft   = LeftMargin + Day1Column*BoxWidth + TextOffset
  129.        DrawTextBlock 1 TextLeft TextBottom Event
  130.     End
  131.     else do until Day1Row > Day2Row
  132.        SearchPos = 1
  133.        Found = 1
  134.        TextRows = 1
  135.        do until Found = 0
  136.           Found = pos('//',Event,SearchPos)
  137.           if Found > 0 then do
  138.              Text.TextRows = substr(Event,SearchPos,Found - SearchPos)
  139.              SearchPos = Found + 2
  140.              TextRows = TextRows + 1
  141.           end
  142.           else Text.TextRows = substr(Event,SearchPos)
  143.           end
  144.  
  145.           if Day2Row > Day1Row then Width = (LeftMargin + 7*BoxWidth) - LeftEdge - 4
  146.           else Do
  147.              Day2Column = (Day2 + StartDate) - 7*Day2Row - 1
  148.              Width = (LeftMargin + (Day2Column + 1)*BoxWidth - TextOffset) - LeftEdge - 2
  149.           End
  150.  
  151.           TopEdge = TopMargin + TextArea + PrintRow + Line*FSize*11 + trunc(2.5*FSize)
  152.           DrawBox 1 LeftEdge TopEdge Width FSize*11*TextRows
  153.  
  154.           do i = 1 to TextRows
  155.              TextBottom = TopMargin + TextArea + PrintRow + (Line+i)*FSize*11
  156.              DrawTextBlock 1 1 TextBottom Text.i
  157.              ID = RESULT
  158.              GetObjectCoords ID
  159.              parse var result . . . TextWidth TextHeight
  160.              TextLeft = trunc(LeftEdge + (Width - TextWidth)/2)
  161.              SetObjectCoords ID 1 TextLeft TextBottom TextWidth TextHeight
  162.           end
  163.  
  164.           Day1Row = Day1Row + 1
  165.           If Day1Row < 5 then PrintRow = Day1Row * BoxHeight
  166.           else PrintRow = trunc(4.5 * BoxHeight)
  167.           LeftEdge = LeftMargin - 1
  168.        End
  169.     Redraw
  170.     SelectObject
  171.  End
  172.